const data = [
    {
        name: "Kris",
        age: "21"
    },
    {
        name: "Kris",
        age: "22"
    },
    {
        name: "Kitty",
        age: "22"
    },
    {
        name: "Andy",
        age: "23"
    },
    {
        name: "Kitty",
        age: "24"
    },
    {
        name: "Andy",
        age: "25"
    },
    {
        name: "Kitty",
        age: "26"
    }
]
const dataReducer = (prev, cur, idx) => {
    console.log(prev);
    console.log(cur);
    console.log('-------------------------');
    let obj = {}
    const { name } = cur
    obj[name] = cur
    console.log(idx);
    return {
        ...prev,
        ...obj
    }
}
const reducedData = data.reduce(dataReducer, {});
let newData = Object.values(reducedData);
console.log(newData);
console.log(reducedData);